<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>常用方法 | 诚毅物联网</title>
    <meta name="description" content="前端常用方法汇总">
    <link rel="icon" href="/favicon.ico">
    
    <link rel="preload" href="/assets/css/0.styles.8a682027.css" as="style"><link rel="preload" href="/assets/js/app.af065b41.js" as="script"><link rel="preload" href="/assets/js/2.873788d5.js" as="script"><link rel="preload" href="/assets/js/5.9e943e07.js" as="script"><link rel="prefetch" href="/assets/js/3.ac7ca61d.js"><link rel="prefetch" href="/assets/js/4.16a2e1e1.js"><link rel="prefetch" href="/assets/js/6.21f46f41.js"><link rel="prefetch" href="/assets/js/7.97760cdd.js">
    <link rel="stylesheet" href="/assets/css/0.styles.8a682027.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">诚毅物联网</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/Fun/" class="nav-link router-link-exact-active router-link-active">文档</a></div><div class="nav-item"><a href="/about/" class="nav-link">使用手册</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/Fun/" class="nav-link router-link-exact-active router-link-active">文档</a></div><div class="nav-item"><a href="/about/" class="nav-link">使用手册</a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>常用方法</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/Fun/#手机号正则验证" class="sidebar-link">手机号正则验证</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="常用方法"><a href="#常用方法" class="header-anchor">#</a> 常用方法</h1> <h2 id="手机号正则验证"><a href="#手机号正则验证" class="header-anchor">#</a> 手机号正则验证</h2> <ol><li>本 demo 为 TS 使用,JS 使用将参数 <code>num:string</code> 删除。</li> <li>参数为单个参数,返回 true/false</li> <li>手机号段具有不稳定性，使用前请效验准确性。</li></ol> <div class="language-javascript extra-class"><pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">RegPhone</span><span class="token punctuation">(</span><span class="token parameter">num<span class="token punctuation">:</span> string</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> Rge <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span><span class="token regex">/^(13[0-9]|15[^4]|18[0-9]|17[0-8]|147)\d{8,8}$/</span><span class="token punctuation">)</span>
  <span class="token keyword">return</span> Rge<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>num<span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.af065b41.js" defer></script><script src="/assets/js/2.873788d5.js" defer></script><script src="/assets/js/5.9e943e07.js" defer></script>
  </body>
</html>
